define(
   [
      'dojo/_base/declare'
   ],
   function(declare)
   {
      var pDeclared = declare([],
      {
         constructor:function (args)
         {
            // Call Super
            dojo.safeMixin(this, args);
            
            this.randLength   = 8;
            this.sForms        = [];
         },
         postscript: function(args)
         {
            // Called after constructors
            this.inherited(arguments);
         },
         add:function(form)
         {
            this.sForms.push(form);
         },
         remove:function(form)
         {
            for(var i in this.sForms)
            {
               if(!this.sForms.hasOwnProperty(i))
                  continue;

               if(this.sForms[i] == form)
               {
                  this.sForms.splice(i, 1);
                  return true;
               }
            }
            return false;
         },
         getUniqueId:function()
         {
            var rstring = this.randomeString(this.randLength);
            for(var i in this.sForms)
            {
               if(!this.sForms.hasOwnProperty(i))
                  continue;

               if(this.sForms[i].id == rstring)
               {
                  return this.getUniqueId();
               }
            }
            return rstring;
         },
         randomeString:function(length)
         {
            var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
            var randomstring = '';
            for (var i = 0; i < length; i++) {
               var rnum = Math.floor(Math.random() * chars.length);
               randomstring += chars.substring(rnum, rnum+1);
            }
            return randomstring;
         }

      });

      pDeclared.sForms = new Array();   // static beacuse arrays and objects are static unless set in constructor

      return pDeclared;
   }
);

